package com.mew.lobby.net;


import com.mew.common.rest.LongMessage;
import com.mew.common.rest.feedback.FeedbackRequestMessage;
import com.mew.common.rest.gold.TranRequest;
import com.mew.lobby.message.request.*;
import com.mew.common.rest.IntMessage;
import com.mew.common.rest.StringMessage;
import com.zebra.remoting.config.EmptyMessage;
import com.zebra.remoting.protocol.CommandCode;
import com.zebra.remoting.protocol.CommandType;
import com.zebra.remoting.protocol.PoolType;
import com.zebra.remoting.protocol.ProcessorType;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;


public enum LobbyHandlerMapCmdType implements CommandCode {

    //1000-1010  登录
    LoginLobby(1001, ProcessorType.L_LOGIN, PoolType.EXECUTOR,    EnterLobbyRequestMessage.class), //, "游客登录"
    ReconnectionLobby(1011, ProcessorType.L_RECON,  PoolType.EXECUTOR,   EnterLobbyRequestMessage.class), //重连大厅 需要校验
    SwitchAccount(1012,  EmptyMessage.class),  //切换账号 相当于退出

    //1013开始 用户相关
    UserInfo(1013,   EmptyMessage.class),//用户信息
    Achievement(1014,    EmptyMessage.class),//成就
    NickName(1015,    StringMessage.class),  //修改昵称
    Head(1016,    IntMessage.class),  //修改头像
    Signature(1017,    StringMessage.class),  //修改签名
    Telephone(1018,    BindTelephoneRequestMessage.class),  //绑定手机
    BindInviter(1019,    StringMessage.class),  //绑定邀请人
    MailList(1020,  EmptyMessage.class),//邮件列表
    InviterList(1021,  EmptyMessage.class),//邀请人列表

    UserDetailedInfoByUid(1022,   LongMessage.class),//玩家具体信息 通过uid
    UserDetailedInfoByGid(1023,  StringMessage.class),//玩家具体信息 通过gid

    FriendList(1024,  EmptyMessage.class),//好友列表
    AddFriend(1025,  LongMessage.class),//添加好友
    DelFriend(1026,  LongMessage.class),//删除好友
    FriendApplyList(1027,   EmptyMessage.class),//申请列表
    FriendApplyUpdate(1028,   FriendApplyUpdateRequest.class),//同意或忽略
    FriendGive(1029,   LongMessage.class),//赠送
    FriendGiveAll(1030,   EmptyMessage.class),//全部赠送
    RecommendFriend(1031,  EmptyMessage.class),//推荐好友

    MailReceive(1032,  IntMessage.class),//领取邮件
    MailInfo(1037,  IntMessage.class),//邮件详情
    VipInfo(1033,    EmptyMessage.class),//用户信息

    WorldInfoList(1034,  EmptyMessage.class),//世界消息列表
    LoginInfo(1035,  EmptyMessage.class),//登录提示
    ChatSendInfo(1036,  StringMessage.class),//聊天室 - 发送消息

    AgentUpCode(1038,  EmptyMessage.class),//代理 - 上家代理码
    AgentInfo(1039,  EmptyMessage.class),//代理 - 信息
    AgentBind(1040,  StringMessage.class),//代理 - 綁定
    AgentProfitDay(1041,  EmptyMessage.class),//代理 - 日收益
    AgentProfitWeek(1042,  EmptyMessage.class),//代理 - 周收益
    AgentExtract(1043,  LongMessage.class),//代理 - 提取

    AccountEdit(1044,  EditResponseMessage.class),//修改账号
    PasswordEdit(1045,  EditResponseMessage.class),//修改密码

    //--1100 游戏相关
    GameList(1100,    EmptyMessage.class),
    RoomList(1101,    LoadRoomRequestMessage.class),
    Download(1102,    DownloadGameRequestMessage.class),
//    EnterRoom(1102,    EnterRoomRequestMessage.class), //进房间前检验房间

    //-------活动相关---
    OnlineGiftRefresh(1200,    EmptyMessage.class), //签到信息
    OnlineGiftGet(1201,    IntMessage.class), //签到信息
    Sign(1202,    EmptyMessage.class), //签到信息
    SignGain(1203,    IntMessage.class), //领取
    GoldRank(1204,    IntMessage.class), //排行榜

    //--1300 任务相关

    //--1400 交易
    Customers(1400,    EmptyMessage.class), //商家推荐
    CustomerInfo(1401,    LongMessage.class), //商家信息
    Tran(1402,    TranRequest.class), //交易
    TranRecord(1403,    IntMessage.class), //交易记录
    Jewe2Gold(1404,    IntMessage.class),
//    Money2Jewe(1405,    BuyRequestMessage.class),
    GoldBuyInfo(1406,    EmptyMessage.class),
    JeweAll2Gold(1407,    LongMessage.class),
    TranSMS(1408,    BindTelephoneRequestMessage.class),//开通转账功能


    //sys
    Bulletin(1500,    EmptyMessage.class),

    //--1900 工具
    SMS(1901,    StringMessage.class),  //发短信
    FEEDBACK(1902,    FeedbackRequestMessage.class),  //反馈
    GuideType(1903,    IntMessage.class)    //新手引导
    ;

    private int cmd ;
    private CommandType commandType;
    private ProcessorType processorType;
    private PoolType poolType;
    private boolean verifyType;
    private final Class request;

    LobbyHandlerMapCmdType(int cmd, ProcessorType processorType, PoolType poolType,   Class request){
        this.cmd = cmd;
        this.processorType = processorType;
        this.poolType = poolType;
        this.verifyType = true;
        this.request = request;
        this.commandType = CommandType.LOBBY;
    }

    LobbyHandlerMapCmdType(int cmd, ProcessorType processorType, Class request){
        this.cmd = cmd;
        this.processorType = processorType;
        this.poolType = PoolType.DISRUPTOR;
        this.verifyType = true;
        this.request = request;
        this.commandType = CommandType.LOBBY;
    }
    
    LobbyHandlerMapCmdType(int cmd,  Class request){
        this.cmd = cmd;
        this.processorType = ProcessorType.GM;
        this.poolType = PoolType.DISRUPTOR;
        this.verifyType = true;
        this.request = request;
        this.commandType = CommandType.LOBBY;
    }

    @Override
    public int cmd() {
        return this.cmd;
    }

    @Override
    public ProcessorType processorType() {
        return this.processorType;
    }

    @Override
    public Class request() {
        return this.request;
    }


    @Override
    public PoolType poolType() {
        return this.poolType;
    }

    @Override
    public boolean verifyType() {
        return this.verifyType;
    }

    @Override
    public CommandType commandType() {
        return this.commandType;
    }

    //转换成 map
    private  static Map<Integer, CommandCode> handlerTypeMap = Arrays.stream(LobbyHandlerMapCmdType.values())
            .collect(Collectors.toMap(LobbyHandlerMapCmdType::cmd, rtype -> rtype));

    public  static LobbyHandlerMapCmdType valueOfCode(int cmd){
        return (LobbyHandlerMapCmdType) handlerTypeMap.get(cmd);
    }

    public  static Map<Integer, CommandCode> getMap(){
        return handlerTypeMap;
    }




}
